﻿using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] arr = new int[n];
        int l = 1;
        int last = 0;
        int best = 0;
        for (int i = 0; i < n; i++)
        {
            arr[i] = int.Parse(Console.ReadLine());
        }
        for (int i = 0; i < n-1; i++)
        {
            if (arr[i] == arr[i + 1])
            {
                l++;
            }
            else
            {
                l = 1;
            }
            if (best<l)
            {
                last = i + 1;
                best = l;
            }
        }
        for (int i = last-(best-1); i <= last; i++)
        {
            Console.Write(arr[i]+", ");
        }
        Console.WriteLine();
    }
}